// 通过监测effect方法内部使用的参数，参数发生变化，trigger触发器执行，就会产生额方法更新
// 定义dep的类型为Set
let price = 12, quantity = 2, total = 0;
let dep = new Set();
const effect = () => { total = price * quantity}
// track 追踪
const track = () => {
  dep.add(effect)
}
// trigger 触发
const trigger = () =>{
  dep.forEach(effect => effect())
}
track();
trigger();
console.log(`${total}`);
price = 15;
trigger();
console.log(`${total}`);
quantity = 5;
trigger();
console.log(`${total}`);
